]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
lookingGlass: make Esc work on any page
authorDan Winship <danw@gnome.org>
Wed, 20 Apr 2011 16:41:22 +0000 (12:41 -0400)
committerDan Winship <danw@gnome.org>
Mon, 16 May 2011 10:43:47 +0000 (06:43 -0400)
The lg window was losing focus when the page with the entry got unmapped;
fix it to refocus itself after that.

Fixing this problem revealed that previously we were focusing the
entry on open(), but not ensuring that that page was selected, meaning
you could type into the entry without being able to see it. Fix that.

https://bugzilla.gnome.org/show_bug.cgi?id=647303

js/ui/lookingGlass.js

index 2c97cc5190cb6252b490cd8f89be66646b3d10f6..6e6e22a0be430b46f6c71d02bb5b139f1ba30079 100644 (file)
@@ -5,6 +5,7 @@ const Cogl = imports.gi.Cogl;
 const GConf = imports.gi.GConf;
 const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
+const Gtk = imports.gi.Gtk;
 const Pango = imports.gi.Pango;
 const St = imports.gi.St;
 const Shell = imports.gi.Shell;
@@ -100,12 +101,19 @@ Notebook.prototype = {
     selectIndex: function(index) {
         if (index == this._selectedIndex)
             return;
-        this._unselect();
         if (index < 0) {
+            this._unselect();
             this.emit('selection', null);
             return;
         }
+
+        // Focus the new tab before unmapping the old one
         let tabData = this._tabs[index];
+        if (!tabData.scrollView.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false))
+            this.actor.grab_key_focus();
+
+        this._unselect();
+
         tabData.labelBox.add_style_pseudo_class('selected');
         tabData.scrollView.show();
         this._selectedIndex = index;
@@ -745,12 +753,7 @@ LookingGlass.prototype = {
         let label = new St.Label({ text: 'js>>> ' });
         entryArea.add(label);
 
-        this._entry = new St.Entry();
-        /* unmapping the edit box will un-focus it, undo that */
-        notebook.connect('selection', Lang.bind(this, function (nb, child) {
-            if (child == this._evalBox)
-                global.stage.set_key_focus(this._entry);
-        }));
+        this._entry = new St.Entry({ can_focus: true });
         entryArea.add(this._entry, { expand: true });
 
         this._windowList = new WindowList();
@@ -909,6 +912,7 @@ LookingGlass.prototype = {
         if (!Main.pushModal(this._entry))
             return;
 
+        this._notebook.selectIndex(0);
         this.actor.show();
         this.actor.lower(Main.chrome.actor);
         this._open = true;